package com.share.wechat.core.controller;

import com.share.wechat.core.entity.CarouselFigure;
import com.share.wechat.core.service.CarouselFigureService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/core/detail/")
public class CarouselFigureController {
    @Value("${image.file.url}")
    private String PHOTO_URL;


    @Resource
    private CarouselFigureService carouselFigureService;
    private final Logger logger = Logger.getLogger(this.getClass());

    @GetMapping("getCarouse")
    public List<CarouselFigure> getCarouselFigures() {
        logger.info("请求轮播首页图");
        List<CarouselFigure> carousels = carouselFigureService.getIndexCarousel();
        logger.info("请求到的数据为");
        logger.info(carousels);
        for (CarouselFigure c : carousels) {
            c.setImageUrl(PHOTO_URL + c.getImageUrl());
        }
        return carousels;
    }

}
